stylecontext: Make first property name explicit
authorBenjamin Otte <otte@redhat.com>
Fri, 10 Nov 2017 13:53:36 +0000 (14:53 +0100)
committerBenjamin Otte <otte@redhat.com>
Fri, 10 Nov 2017 13:56:42 +0000 (14:56 +0100)
Insist that a first non-NULL property is passed to
gtk_style_context_get().

This is in particular relevant because of dropping the state argument
since GTK3, and code like
  gtk_style_context_get (context, state, "font", &font);
would keep compiling without warnings without this change.

gtk/gtkstylecontext.c
gtk/gtkstylecontext.h

index 02955e9c9e05b2a3ee0d0b8c344c0529f8fe8d57..f70bc3a8b6600b6bc73b8a44a0037ac9376db09f 100644 (file)
@@ -749,6 +749,7 @@ gtk_style_context_get_property (GtkStyleContext *context,
 /**
  * gtk_style_context_get_valist:
  * @context: a #GtkStyleContext
+ * @first_property_name: Name of the first property
  * @args: va_list of property name/return location pairs, followed by %NULL
  *
  * Retrieves several style property values from @context for a given state.
@@ -765,13 +766,15 @@ gtk_style_context_get_property (GtkStyleContext *context,
  */
 void
 gtk_style_context_get_valist (GtkStyleContext *context,
+                              const char      *first_property_name,
                               va_list          args)
 {
   const gchar *property_name;
 
   g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
+  g_return_if_fail (first_property_name != NULL);
 
-  property_name = va_arg (args, const gchar *);
+  property_name = first_property_name;
 
   while (property_name)
     {
@@ -799,6 +802,7 @@ gtk_style_context_get_valist (GtkStyleContext *context,
 /**
  * gtk_style_context_get:
  * @context: a #GtkStyleContext
+ * @first_property_name: Name of the first property
  * @...: property name /return value pairs, followed by %NULL
  *
  * Retrieves several style property values from @context for a
@@ -816,14 +820,16 @@ gtk_style_context_get_valist (GtkStyleContext *context,
  */
 void
 gtk_style_context_get (GtkStyleContext *context,
+                       const char      *first_property_name,
                        ...)
 {
   va_list args;
 
   g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
+  g_return_if_fail (first_property_name != NULL);
 
-  va_start (args, context);
-  gtk_style_context_get_valist (context, args);
+  va_start (args, first_property_name);
+  gtk_style_context_get_valist (context, first_property_name, args);
   va_end (args);
 }
 
index 58da54d1323eb427b12eb79a2092582a52d5375f..0b58d5e2f06b440dd617c32f427ac66c3c8a6787 100644 (file)
@@ -1005,9 +1005,11 @@ void gtk_style_context_get_property (GtkStyleContext *context,
                                      GValue          *value);
 GDK_AVAILABLE_IN_ALL
 void gtk_style_context_get_valist   (GtkStyleContext *context,
+                                     const char      *first_property_name,
                                      va_list          args);
 GDK_AVAILABLE_IN_ALL
 void gtk_style_context_get          (GtkStyleContext *context,
+                                     const char      *first_property_name,
                                      ...) G_GNUC_NULL_TERMINATED;
 
 GDK_AVAILABLE_IN_ALL